let EnterTimeout: any = null
const panoramaId = 'VR'

export const initVR = async () => {
  await fdapi.panorama.add({
    id: panoramaId,
    imagePath: '@path:孪创城市/东方之门.jpg',
    coordinate: [564536.056016, 3466569.477578, 233.196602],
    coordinateType: 0, //坐标系类型，取值范围：0为Projection类型，1为WGS84类型，2为火星坐标系(GCJ02)，3为百度坐标系(BD09)，默认值：0
    yaw: -48, //方向
    onTerrain: false, //是否贴地，注意：设置为贴地后offset偏移量的Z轴会失效
    offset: [0, 0, 0] //偏移量
  })

  fdapi.camera.set(564536.056016, 3466569.477578, 233.196602, -2.069732, 169.979553, 2)
  EnterTimeout = setTimeout(() => {
    fdapi.panorama.enter(panoramaId)
  }, 2000)
}

export const exitVR = async () => {
  await fdapi.panorama.exit()
  await fdapi.panorama.delete(panoramaId)
  if (EnterTimeout) clearTimeout(EnterTimeout)
}
